﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Collections;
using System.Drawing.Printing;
using System.Runtime.Serialization.Formatters.Binary;

//Created: 10/22/08
//Last Modified: 
// v0.80	- 10/22/08 @11:14PM	- Init. version.
// v0.85	- 10/23/08			+ Printing, TreeView Hilighting.
// v0.86	- 10/24/08			+ Batch creation.
// v0.861	- 10/29/08			+ Filter icon, minor version change.
// v0.87	- 10/30/08			+ Fixes for saving a userdata.
// v0.88	- 11/01/08 @8:24PM	+ View menu and Status Bar hide/show.
// v0.881	- 11/01/08 @8:36PM	+ Fixing print preview timestamp.
// v0.882   - 11/27/08 @5:27PM  + B3.

//Bug(s):
// B1: <Module: Printing>: If there's more then one page of data it prints the same page repeatedly.
// B2: <>: Saving of the userData is only saving the 'sessions' change.
// B3: If no valid Printer is installed the application throws an exception.

// Testing.

//ToDo(s):
// <Modudle: Batch>: Allow user to specify the filename of the batch file.
//

namespace CreateDirectoryStructure
{
    public partial class Form1 : Form
	{

		#region Global Variables
			//Global Variables...
			string gApplicationName = "DirST";
			string gApplicationAuthor = "StewART Whaley";

			string gDirectory = "";
			string cStrCreateDirectoryStructure = "Creates a Directory structure of all the items checked in the left view under the directory: ";
			string cStrDefaultMsg = "DirST - Allows one to copy directory structures.";
			string gPrintHeader = "DirST: " + System.DateTime.Now.ToString();
			int gPrintLineNumbers = 1;
			bool gBPrintLineNumbers = true;
			Dirst gDirst = new Dirst();
			TreeView gActiveTreeView = new TreeView();
			

			private PageSettings pgSettings = new PageSettings();
			Font gPrintFont = new Font("Courier New", 10);
			int gPrintLineY, gPrintLeftMargin, gPrintTopMargin = 0;

			Stack collCheckedItems = new Stack();

		#endregion //Global Variables


		public Form1()
        {
            InitializeComponent();
        }

		//Init Form...
		private void Form1_Load(object sender, EventArgs e)
		{
			CBox_Filter.SelectedIndex = 0;

		}//Form1_Load

		private void Form1_Shown(object sender, EventArgs e)
		{
			loadUserData();
			gActiveTreeView = treeView_Source;
		}//Form1_Shown

        void getSource()
        {
            folderBrowserDialog1.ShowDialog();
            gDirectory = folderBrowserDialog1.SelectedPath.ToString();
            displayDirectoryPath();

            try
            {
                DirectoryInfo dir = new DirectoryInfo(gDirectory);
            }
            catch (Exception e)
            {
                displayStatusBarError("Error:" + e.ToString());
            }//try

            addItemToCBox(CBox_Source, gDirectory, gDirectory, true);

            //readDirectoryPopulateTree(gDirectory, true);
        }//start

        string displayBrowser()
        {
            string tempDir = "";
            folderBrowserDialog1.ShowDialog();
            tempDir = folderBrowserDialog1.SelectedPath.ToString();
            return (tempDir);
           // addItemToCBox(CBox_Destination, tempDir, tempDir, true);
        }//displayBrowser

        void readDirectoryPopulateTree(string myDirectory, bool addToCombox)
        {
            // Dim dir As DirectoryInfo = New DirectoryInfo("c:\")
            DirectoryInfo dir = new DirectoryInfo(myDirectory);
            // addItemToCBox(myDirectory, myDirectory, addToCombox);

            getFolders(dir, getFilter(), true, getSearchOptions());
        }//readDirectoryPopulateTree

        string getFilter()
        {
            return ( CBox_Filter.Text.ToString() );
		}//getFilter

        SearchOption getSearchOptions()
        {
            if (Btn_FilterOnOff.CheckState == CheckState.Checked)
            {
                return (SearchOption.AllDirectories);

            }
            else
            {
                return (SearchOption.TopDirectoryOnly);
            }

        }//getSearchOptions

        //Display the users choosen directory path.
        void displayDirectoryPath()
        {
           // TBox_Folder.Text = gDirectory;

        }//displayDirectoryPath

        void getFolders(DirectoryInfo dir, string filterText, bool bClearExisitingNodes, SearchOption mySearchOption)
        {
            //FIND ALL FOLDERS IN FOLDER
            //System.IO.DirectoryInfo g;
            TreeNode newNode ;  //= new TreeNode();
            TreeNode topNode = new TreeNode();

			


            stripPBar.Minimum = 0;

            //Check if Filter option is turn ON/OFF
            if (Btn_Filter.Checked != true)
            {
                filterText = "*.*";
            }//if

            //Check if they are allowed to access the specified directory.
            try
            {
                stripPBar.Maximum = dir.GetDirectories(filterText, mySearchOption).Count();    
            }
            catch (Exception e)
            {
                //statusBar_Message.Text = "Error:" + e.ToString();
                displayStatusBarError("Error:" + e.ToString());
            }//try



            stripPBar.Value = 0;        //Init. Progress Bar, 1 because the, 'deleteAllTreeNodes' might take a bit.
            if (bClearExisitingNodes == true)
            {
                deleteAllTreeNodes();
            }

           //TreeNode Main = treeView_Source.Nodes.Add(dir.FullName.ToString());
           // Main.Tag = "";
            TreeNode Main = new TreeNode();
            Main.Text = dir.FullName.ToString();
            Main.Tag = "";
            Main.Checked = true;

            ////Main.Nodes.Add(topNode);
            treeView_Source.Nodes.Add(Main);



        
          try
            {
            foreach (System.IO.DirectoryInfo g in dir.GetDirectories(filterText, mySearchOption))
            {
                //LOAD FOLDERS
                newNode = new TreeNode();

                newNode.Text = g.FullName;
                newNode.Tag = (g.FullName);
                newNode.Checked = true;

                //TreeNode MainNext = Main.Nodes.Add(g.FullName);
                Main.Nodes.Add(newNode);

                //MainNext.Tag = (g.FullName);
                stripPBar.PerformStep();        //Increment Progress Bar

            }//foreach
           }//try
            catch (Exception e)
            {
                //statusBar_Message.Text = "Error:" + e.ToString();
                displayStatusBarError("Error:" + e.ToString());
            }

		  Main.ExpandAll();

        }

        void addItemToCBox(ComboBox cBox, string nodeName, string nodeText, bool addItem)
        {
            //System.Windows.Forms.TreeNode treeNode = new System.Windows.Forms.TreeNode("sourceAdd");

           // treeNode.Name = nodeName;
            //treeNode.Text = nodeText;
            //this.treeView_Source.Nodes.AddRange(new System.Windows.Forms.TreeNode[] { treeNode });
            if (addItem == true)
            {
                cBox.Items.AddRange(new object[] { nodeName });
                cBox.SelectedItem = nodeName;    //Select for the user the newly added item.
                addItemToCollection(nodeName);
                
            }//if
        }//addItemToCBox

        void addItemToCollection(object obj)
        {
            gDirst.collCheckedItems.Push(obj); //Add to our serializable obj.
        }

        private void menuFileOpen_Click(object sender, EventArgs e)
        {
            getSource();
        }

        private void stripBtn_Create_Click(object sender, EventArgs e)
        {
            getSource();
        }

        private void CBox_Source_SelectedIndexChanged(object sender, EventArgs e)
        {
            CBoxSourceChanged();
            setCreateDirectoryStructureTooltip();

        }//CBox_Source_SelectedIndexChanged

        void setCreateDirectoryStructureTooltip()
        {
            Btn_CreateDirectoryStructure.ToolTipText = cStrCreateDirectoryStructure + CBox_Destination.Text;
        }

        private void CBox_Destination_SelectedIndexChanged(object sender, EventArgs e)
        {
            CBoxDestinationChanged();
        }//CBox_Destination_SelectedIndexChanged

        void CBoxSourceChanged()
        {

            resetStatusBarText();

           // deleteAllTreeNodes();
            if (CBox_Source.SelectedIndex != 0)
            {
                readDirectoryPopulateTree(CBox_Source.SelectedItem.ToString(), false);
            }
            else
            {
                //User choose the, 'Browse...' menu-item.
                getSource();
            }

        }//CBoxSourceChanged()

        void CBoxDestinationChanged()
        {
            string tempDir;

            // deleteAllTreeNodes();
            if (CBox_Destination.SelectedIndex != 0)
            {
               // readDirectoryPopulateTree(CBox_Source.SelectedItem.ToString(), false);
            }
            else
            {
                //User choose the, 'Browse...' menu-item.
                tempDir = displayBrowser();
                addItemToCBox(CBox_Destination, tempDir, tempDir, true);
            }//if

            setCreateDirectoryStructureTooltip();
        }//CBoxDestinationChanged

        void deleteAllTreeNodes()
        {
            treeView_Source.Nodes.Clear();
        }//deleteAllTreeNodes

        private void openToolStripButton_Click(object sender, EventArgs e)
        {
            getSource();
        }//openToolStripButton_Click

        private void menuTools_CreateDirectoryStructure_Click(object sender, EventArgs e)
        {
            CreateDirectoryStructure();
        }

        private void Btn_CreateDirectoryStructure_Click(object sender, EventArgs e)
        {
            CreateDirectoryStructure();
        }//Btn_CreateDirectoryStructure_Click

        void CreateDirectoryStructure()
        {
            statusBar_Message.Text = treeView_Source.Nodes.Count.ToString();

            collCheckedItems.Clear();           //Clear out collection.
            CallRecursive(treeView_Source);

        }//CreateDirectoryStructure

        private void PrintRecursive(TreeNode treeNode, TreeNode mainBranch)
        {
            // Print the node.
            // System.Diagnostics.Debug.WriteLine(treeNode.Text);
            // MessageBox.Show(treeNode.Text);
			////http://msdn.microsoft.com/en-us/library/wwc698z7.aspx 
           

            if (treeNode.Checked == true)
            {
                TreeNode MainNext = mainBranch.Nodes.Add(treeNode.Text.ToString());
                MainNext.Tag = (treeNode.Text.ToString());
                //collCheckedItems.Add(treeNode.Text.ToString(), treeNode.Text.ToString());
                collCheckedItems.Push(treeNode.Text.ToString());

            }//if

            // Print each node recursively.
            foreach (TreeNode tn in treeNode.Nodes)
            {
                PrintRecursive(tn, mainBranch);
            }//foreach
        }//PrintRecursive

        private void CallRecursive(TreeView treeView)
        {
            TreeNode Main = treeView_Destination.Nodes.Add("Directories Created: " + System.DateTime.Now.ToString());
            Main.Tag = "";

            // Print each node recursively.
            TreeNodeCollection nodes = treeView.Nodes;
            foreach (TreeNode n in nodes)
            {
                PrintRecursive(n, Main);
            }//foreach

            statusBar_Message.Text = "# of checked Items: " + collCheckedItems.Count.ToString();
            createDirectories(collCheckedItems);
			
			Main.ExpandAll();

        }//CallRecursive

        void createDirectories(Stack myColl)
        {
            debugStr("***createDirectories()");

            string tempDir = "";
            string destinationDir = getDestinationDirectory();
            string fullDestinationDir = "";


            foreach (string str in myColl)
            {
                debugStr(str);
                tempDir = stripDirectoryName(str);
                fullDestinationDir = destinationDir + tempDir;
                debugStr("Create Directory: " + fullDestinationDir);

                createDirectory(fullDestinationDir);
            }
        }//createDirectories

        void createDirectory(string dirName)
        {
            Directory.CreateDirectory(@dirName);

        }//createDirectory

        //TO DO: Account for network drives, etc...
        string stripDirectoryName(string dirName)
        {
            return (dirName.Substring(2));
        }//stripDirectoryName

        string getDestinationDirectory()
        {
            return (CBox_Destination.Text.ToString());
        }//getDestinationDirectory

        void debugStr(string str)
        {
            System.Diagnostics.Debug.WriteLine(str.ToString());
        }//debugStr

		void DebugOutput(string str)
		{
			Console.WriteLine(str);
		}//DebugOutput

		void displayStatusBarText(string str)
		{
			statusBar_Message.Text = str;
		}//displayStatusBarText

		void resetStatusBarText()
		{
			statusBar_Message.ForeColor = Color.Black;
			statusBar_Message.Text = cStrDefaultMsg;
		}//resetStatusBarText

		void displayStatusBarError(string str)
		{
			statusBar_Message.ForeColor = Color.Red;
			statusBar_Message.Text = str;
		}//displayStatusBarError

        private void menuCheckAll_Click(object sender, EventArgs e)
        {
            checkNodesAll(treeView_Source, true);
        }//menuCheckAll_Click

        private void menuUncheckAll_Click(object sender, EventArgs e)
        {
            checkNodesAll(treeView_Source, false);
        }//menuUncheckAll_Click

        private void checkNodeRecursive(TreeNode treeNode, bool checkStatus)
        {
            // Print the node.
            // System.Diagnostics.Debug.WriteLine(treeNode.Text);
            // MessageBox.Show(treeNode.Text);

            treeNode.Checked = checkStatus;
            
            // Print each node recursively.
            foreach (TreeNode tn in treeNode.Nodes)
            {
                checkNodeRecursive(tn, checkStatus);
            }//foreach

        }//checkNodeRecursive

        private void checkNodesAll(TreeView treeView, bool checkStatus)
        {
            //TreeNode Main = treeView_Destination.Nodes.Add("Checked Source Items");
           // Main.Tag = "";

            // Print each node recursively.
            TreeNodeCollection nodes = treeView.Nodes;
            foreach (TreeNode n in nodes)
            {
                checkNodeRecursive(n, checkStatus);
            }//foreach

            statusBar_Message.Text = "# of checked Items: " + collCheckedItems.Count.ToString();
            //createDirectories(collCheckedItems);

        }//checkNodesAll

        private void menuFile_Browse_Click(object sender, EventArgs e)
        {
            getSource();
        }//menuFile_Browse_Click

        private void menuRefresh_Click(object sender, EventArgs e)
        {
            CBoxSourceChanged();
        }//menuRefresh_Click




        #region Printing
        //Code for Printing function(s)...
        //http://www.ondotnet.com/pub/a/dotnet/2002/06/24/printing.html
        //http://www.codeproject.com/KB/printing/simpleprintingcs.aspx
		//ms-help://MS.VSCC.v90/MS.MSDNQTR.v90.en/fxref_system.windows.forms/html/4e7ce087-e335-6a82-df14-d7660a35ad0e.htm
		
        private void menuFile_Print_Click(object sender, EventArgs e)
        {
			Print();
        }//menuFile_Print_Click

		private void Btn_Print_Click(object sender, EventArgs e)
		{
			Print();
		}//Btn_Print_Click

		void Print()
		{
			resetStatusBarText();

            printDocument.DefaultPageSettings = pgSettings;
            PrintDialog dlg = new PrintDialog();
            dlg.Document = printDocument;
            if (dlg.ShowDialog() == DialogResult.OK) 
            {
                printDocument.Print();
            }//if
		}//Print

        private void printDocument_PrintPage(object sender, PrintPageEventArgs e)
        {
            //String textToPrint = "Printing line 1.";
            Font printFont = new Font("Courier New", 12);
            gPrintLeftMargin = e.MarginBounds.Left;
            gPrintTopMargin = e.MarginBounds.Top;
            gPrintLineY = gPrintTopMargin;
            gPrintLineNumbers = 1;


            e.Graphics.DrawString(gPrintHeader, printFont, Brushes.Blue, gPrintLeftMargin, gPrintLineY);
            gPrintLineY += 15;
           // e.Graphics.DrawString("Here is the 2nd line", printFont, Brushes.Blue, gPrintLeftMargin, gPrintLineY);
           // gPrintLineY += 15;

			printNodesAll(gActiveTreeView, e);

            if (gPrintLineY >= e.MarginBounds.Bottom)
            {
                e.HasMorePages = true;
                return;
            }
            else
            {
                e.HasMorePages = false;
            }//if


        }//printDocument_PrintPage

        private void printNodeRecursive(TreeNode treeNode, PrintPageEventArgs e)
        {
            // Print the node.
            // System.Diagnostics.Debug.WriteLine(treeNode.Text);
            // MessageBox.Show(treeNode.Text);

            string textToPrint = "";

            textToPrint = treeNode.Text;

            if (gBPrintLineNumbers == true)
            {
                textToPrint = gPrintLineNumbers.ToString() + " " + treeNode.Text;
            }

            e.Graphics.DrawString(textToPrint, gPrintFont, Brushes.Black, gPrintLeftMargin, gPrintLineY);
            gPrintLineY += 15;
            gPrintLineNumbers += 1;     //Increment Line Numbers.

            // Print each node recursively.
            foreach (TreeNode tn in treeNode.Nodes)
            {
                printNodeRecursive(tn,  e);
            }//foreach

        }//checkNodeRecursive

        // Call the procedure using the TreeView.
        private void printNodesAll(TreeView treeView, PrintPageEventArgs e)
        {
            //TreeNode Main = treeView_Destination.Nodes.Add("Checked Source Items");
            // Main.Tag = "";

            // Print each node recursively.
            TreeNodeCollection nodes = treeView.Nodes;
            foreach (TreeNode n in nodes)
            {
                printNodeRecursive(n, e);
            }//foreach

            statusBar_Message.Text = "Printing Completed!";
            //createDirectories(collCheckedItems);

        }//checkNodesAll

        private void menuFile_PrintPreview_Click(object sender, EventArgs e)
        {
			resetStatusBarText();
			gPrintHeader = "DirST: " + System.DateTime.Now.ToString();

            PrintPreviewDialog dlg = new PrintPreviewDialog();
			defaultWindowSize(dlg);

            dlg.Document = printDocument;
			dlg.ShowDialog(); //Bug #B3 - If no valid printer is installed exception thrown!
        }//menuFile_PrintPreview_Click

		void defaultWindowSize(PrintPreviewDialog dlg)
		{
			//create an object of class Rectangle   (rect)
			Rectangle rect = new Rectangle();
			//rect get data from the function returning the working area of the screen
			rect = Screen.GetWorkingArea(this);
			rect.X = 0;
			rect.Y = 0;
			//rect.Location.X = 0;
			//	rect.Location.Y = 0;

			//Screen.
			//rect.Left = 0;
			//rect.Top = 0;

			dlg.ClientSize = new System.Drawing.Size(1500, 1000);
			dlg.Location = new  System.Drawing.Point(0, 0);
			

			//place our form at left
			//dlg.Left = 0;
			//dlg.ShowIcon = true;
			//place our form at top
			//dlg.Top = 0;
			//set the size (width and height) of our form as the size of the screen
			//working area
			//dlg.Size = new Size(rect.Width, rect.Height);
			//dlg.Bounds = rect;

			//dlg.SetDesktopLocation(0, 0);
			//dlg.SetDesktopBounds(0, 0, 1600, 1170);
			//dlg.state
			//dlg.set

			//set the caption(text) of the form. The size of the working area is displayed
			//and then the size of the whole screen
			DebugOutput("SCR Working area:" + Screen.GetWorkingArea(dlg).ToString() + " || SCR Real area: " + Screen.GetBounds(dlg).ToString());
		}//defaultWindowSize

        #endregion //Printing




        void saveUserData()
        {
            Stream stream = File.Open("DirST.osl", FileMode.Create);
            BinaryFormatter bformatter = new BinaryFormatter();

            Console.WriteLine("Writing userData Information");
            bformatter.Serialize(stream, gDirst);
            stream.Close();

        }//saveUserData

        void loadUserData()
        {
            //Clear mp for further usage.
            initDirst();
            //gDirst = null;
            Stream stream;
            //Open the file written above and read values from it.

            try
            {
                 stream = File.Open("DirST.osl", FileMode.Open);
			}
			catch (Exception e)
			{
				//statusBar_Message.Text = "Error:" + e.ToString();
				displayStatusBarError("Error:" + e.ToString());
				stream  = File.Open("Default.osl", FileMode.Open);
			}

                BinaryFormatter bformatter = new BinaryFormatter();

                Console.WriteLine("Reading Object Information");
                gDirst = (Dirst)bformatter.Deserialize(stream);
                stream.Close();

                //displayStatusBarText("Stack: " + gDirst.collCheckedItems);
                //Console.WriteLine("Employee Name: {0}", mp.EmpName);

			displayStatusBarText("Object Deserialized");
		}//loadUserData

        private void menuFile_Save_Click(object sender, EventArgs e)
        {
            //saveUserData();
            //displayStatusBarText("Save Completed!");
        }//menuFile_Save_Click

        private void menuDebug_LoadData_Click(object sender, EventArgs e)
        {
            loadUserData();
            displayStatusBarText("Load Completed!");

            populateCBox_Source();
            //Console.WriteLine("gDirst Object Information");
            //gDirst.collCheckedItems.ToString();

        }//menuDebug_LoadData_Click

        void populateCBox_Source()
        {
            int i = 0;
            initComboBox();

            // Print each node recursively.
            //foreach (string str in gDirst)
            for (i=0;i<=gDirst.collCheckedItems.Count;i++)
            {
                //printNodeRecursive(tn, e);
                CBox_Source.Items.Add((object)gDirst.collCheckedItems.Pop());

            }//foreach
            displayStatusBarText("Populate CBox_Source Completed!");
        }//populateCBox_Source

        void initComboBox()
        {
            CBox_Source.Items.Clear();
            CBox_Source.Items.Add("Browse...");
           
		}//initComboBox

        void initDirst()
        {
            gDirst.Clear();
        }

		private void menuDebug_ClearData_Click(object sender, EventArgs e)
		{
			initComboBox();
		}//menuDebug_ClearData_Click

		private void menuDebug_SaveData_Click(object sender, EventArgs e)
		{
			saveUserData();
		}//menuDebug_SaveData_Click

		//Toggle Border Color...
		private void treeView_Source_MouseDown(object sender, MouseEventArgs e)
		{
			if (panel_Source.BackColor != SystemColors.ActiveCaption)
			{
				panel_Source.BackColor = SystemColors.ActiveCaption;	//Blue
				panel_Destination.BackColor = SystemColors.Control;		//Brown

				treeView_Source.ForeColor = Color.Black;
				treeView_Destination.ForeColor = SystemColors.GrayText;

				gActiveTreeView = treeView_Source;
			}//if

		}//treeView_Source_MouseDown

		private void treeView_Destination_MouseDown(object sender, MouseEventArgs e)
		{
			if (panel_Destination.BackColor != SystemColors.ActiveCaption)
			{
				panel_Destination.BackColor = SystemColors.ActiveCaption;
				panel_Source.BackColor = SystemColors.Control;		//Brown

				treeView_Destination.ForeColor = Color.Black;
				treeView_Source.ForeColor = SystemColors.GrayText;

				gActiveTreeView = treeView_Destination;
			}//if
		}//treeView_Destination_MouseDown




		#region BatchFile
		//Write a Windows Batch File...

		private void menuDebug_SaveBatchFile_Click(object sender, EventArgs e)
		{
			WriteToFile();
		}//menuDebug_SaveBatchFile_Click

	    void WriteToFile()
		{
			StreamWriter streamWrt;
			streamWrt = File.CreateText("c:\\DirST.txt");

			streamWrt.WriteLine("REM Batch file created with " + gApplicationName + ". Written by:" + gApplicationAuthor);
			streamWrt.WriteLine("ECHO Creating Directories...");
			

			writeNodesAll(treeView_Source);
			createMkDirEntries(collCheckedItems, streamWrt);

			//streamWrt.WriteLine("God is greatest of them all");
			//streamWrt.WriteLine("This is second line");
			streamWrt.WriteLine("PAUSE");
			streamWrt.Close();
			Console.WriteLine("Batch File Created SucacessFully");
			displayStatusBarText("Batch File Created SucacessFully");

		}//WriteToFile

		void createMkDirEntries(Stack myColl, StreamWriter strmWrt)
		{
			debugStr("***createMkDirEntries()");

			string tempDir = "";
			string destinationDir = getDestinationDirectory();
			string fullDestinationDir = "";
			string mkCmd = "";

			foreach (string str in myColl)
			{
				debugStr(str);
				tempDir = stripDirectoryName(str);
				fullDestinationDir = destinationDir + tempDir;
				debugStr("Directory: " + fullDestinationDir);

				mkCmd = createMkDirEntry(fullDestinationDir);
				strmWrt.WriteLine(mkCmd);
			}//foreach
		}//createMkDirEntries

		//Format the 'mkdir' command
		string createMkDirEntry(string str)
		{
			string mkDirCmd = "mkdir ";

			//Need to surround fileName with quote in case there's spaces.
			return (mkDirCmd + "\"" + str + "\"");			
		}//createMkDirEntry

		private void writeNodeRecursive(TreeNode treeNode)
		{
			// Print the node.
			// System.Diagnostics.Debug.WriteLine(treeNode.Text);
			// MessageBox.Show(treeNode.Text);

			string textToPrint = "";
			
			textToPrint = treeNode.Text;

			if (treeNode.Checked == true)
			{
				collCheckedItems.Push(treeNode.Text.ToString());
			}//if


			//SW.WriteLine(mkDirCmd + textToPrint);


			// Print each node recursively.
			foreach (TreeNode tn in treeNode.Nodes)
			{
				writeNodeRecursive(tn);
			}//foreach

		}//writeNodeRecursive

		// Call the procedure using the TreeView.
		private void writeNodesAll(TreeView treeView)
		{
			//TreeNode Main = treeView_Destination.Nodes.Add("Checked Source Items");
			// Main.Tag = "";
			collCheckedItems.Clear();

			// Print each node recursively.
			TreeNodeCollection nodes = treeView.Nodes;
			foreach (TreeNode n in nodes)
			{
				writeNodeRecursive(n);
			}//foreach

		}//writeNodesAll

		#endregion //BatchFile

        private void statusBarToolStripMenuItem_Click(object sender, EventArgs e)
        {
            StatusBar_Strip.Visible = menuView_StatusBar.Checked;
        }

        private void statusBar_Message_Click(object sender, EventArgs e)
        {

        }

	}//form
}//CreateDirectoryStructure
